<!DOCTYPE html>
<html>

<head lang="en">
    <title>找攻略</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategyComment.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <script>
        $(function () {
            var params = getParams();
            if (!params.commentId) {
                return;
            }

            /*获取评论内容*/
            $.get('/strategies/comments/' + params.commentId, function (data) {
                var imgUrlsArr = data.imgUrls.split(";");
                imgUrlsArr.pop();
                var temp = [];
                $.each(imgUrlsArr, function (index, ele) {
                    temp.push({img: ele});
                })
                var imgs = {
                    list: temp
                }
                /*渲染到页面*/
                $(".comment").renderValues(data, {
                    getStar: function (item, value) {
                        var starhtml = '';
                        var unStarhtml = '';
                        var value = parseInt(value);
                        for (let i = 0; i < value; i++) {
                            starhtml += '<i class="fa fa-star"></i>';
                        }
                        for (let i = 0; i < 5 - value; i++) {
                            unStarhtml += '<i class="fa fa-star-o"></i>';
                        }
                        $(item).html(starhtml + unStarhtml);
                    },
                    getHref: function (item, value) {
                        var href = $(item).data("href");
                        $(item).attr("href", href + value);
                    }
                });
                $(".myImg").renderValues(imgs);
                /*//绑定点击事件
                $("[data-href]").click(skipHref);*/

                /*图片点击*/
                $(".comment-img img").click(function () {
                    $(document).dialog({
                        titleShow: false,
                        overlayClose: true,
                        content: '<div style="text-align: center;"><img width="100%" src="' + $(this).attr('src') + '"></div>'
                    });
                })
            })


        })
    </script>
</head>
<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>点评详情</span>
        </div>
        <div class="col"></div>
    </div>
</div>

<div class="comment">


    <div class="container ">
        <div class="row">
            <div class="col-2 comment-head">
                <a data-href="userProfiles.html?authorId=" render-key="user.id" render-fun="getHref">
                    <img render-src="user.headImgUrl" class="rounded-circle">
                </a>
                <button class="btn" id="followBtn"><i class="fa fa-hand-o-right"> </i> 关注</button>
            </div>
            <div class="col">
							<span class="comment-star" render-key="starNum" render-fun="getStar">
							</span>

                <span class="comment-date" render-html="createTime"></span>
                <div class="comment-content">
                    <p render-html="content"></p>
                </div>
                <!--渲染评论图片-->
                <div  class="myImg">
                    <ul class="comment-img" render-loop="list">
                        <li>
                            <img render-src="list.img">
                        </li>
                    </ul>
                </div>


                <div class="comment-link">
                    <a data-href="strategyCatalogs.html?strategyId=" render-key="strategy.id" render-fun="getHref">
                        <img render-src="strategy.coverUrl"/> <span render-html="strategy.title"></span>
                        <i class="fa fa-angle-right fa-2x"></i>
                    </a>
                </div>

            </div>
        </div>
    </div>

    <div class="count d-flex justify-content-between">
        <div class="p-2">评论<span id="commentNum">0</span></div>
        <div class="p-2">赞<span id="likeNum">0</span></div>
    </div>

</div>

<div class="comment-list">
    快来发表你的评论吧
</div>

<div class="operation">
    <div class="d-flex justify-content-between">
        <div class="p-2"><i class="fa fa-commenting-o"></i> 添加你的评论</div>
        <div class="p-2"><i class="fa fa-star-o"></i> 收藏</div>
    </div>
</div>

</body>

</html>